// Copyright (C) Kumo inc. and its affiliates.
// Author: Jeff.li lijippy@163.com
// All rights reserved.
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published
// by the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program.  If not, see <https://www.gnu.org/licenses/>.
//


#include <pollux/type/type_util.h>

namespace kumo::pollux::type {
    pollux::RowTypePtr concat_row_types(
        const std::vector<pollux::RowTypePtr> &rowTypes) {
        std::vector<std::string> columnNames;
        std::vector<pollux::TypePtr> columnTypes;
        for (auto &rowType: rowTypes) {
            columnNames.insert(
                columnNames.end(), rowType->names().begin(), rowType->names().end());
            columnTypes.insert(
                columnTypes.end(),
                rowType->children().begin(),
                rowType->children().end());
        }
        return pollux::ROW(std::move(columnNames), std::move(columnTypes));
    }
} // namespace kumo::pollux::type
